<%@page import="com.hgl.entity.Hgl"%>
<%@page import="java.util.function.Supplier"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.List"%>
<%@ page language="java" pageEncoding="UTF-8"%><!DOCTYPE html>
<html>
  <head>
    <title></title>
	<jsp:include page="/admin/head.jsp"/>
  </head>
  <body>
	<jsp:include page="/admin/header.jsp"/>
	<jsp:include page="/admin/left-menu.jsp"><jsp:param value="1" name="index"/></jsp:include>
	<jsp:include page="/admin/footer.jsp"/>



    <!--中间-->
    <section>
      <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
          <li class="breadcrumb-item">管理首页</li>
          <li class="breadcrumb-item">内容管理</li>
          <li class="breadcrumb-item active">新闻中心</li>
        </ol>
      </nav>
      
      <form class="form-inline">
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">新闻类别：</label>
          <select class="form-control">
            <option value="">全部</option>
          </select>
        </div>
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">关键字：</label>
          <input type="text" class="form-control" placeholder="搜索关键字">
        </div>
        <button type="submit" class="btn btn-primary mb-2"><i class="fa fa-search"></i></button>
        <a href="admin/user-add-form.jsp" class="btn btn-success ml-auto mr-2"><i class="fa fa-plus"></i></a>
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">数量：</label>
          <select id=" " class="form-control">
          	<option value="">显示条数</option>
            <option value="5">每页5条</option>
            <option value="10">每页10条</option>
            <option value="20">每页20条</option>
            <option value="50">每页50条</option>
          </select>
        </div>
      </form>
<div class="ml-2 mr-2">
<table class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">帐号</th>
      <th scope="col">昵称</th>
      <th scope="col">性别</th>
      <th scope="col">电话号码</th>
      <th scope="col">出生日期</th>
      <th scope="col">注册时间</th>
      <th scope="col">锁定</th>
      <th scope="col">操作</th>
    </tr>
  </thead>
  <tbody>
  <%
  List<Hgl> list = (List<Hgl>)request.getAttribute("list");
  for(int i=0;i<list.size();i++) {
	  Hgl vo = list.get(i);
  %>
    <tr>
      <th scope="row"><%=i+1 %></th>
      <td><%=vo.getHglName() %></td>
      <td><%=vo.getHglGrade()%></td>
      <td><%=vo.getHglTel() %></td>
      <td><%=format(vo.getHglBirth()) %></td>
      <td>
      <input class="switch" type="checkbox"<%if(new Integer(1).equals(vo.getHglGrade())){ %> checked="checked"<%} %>/>
      </td>
      <td class="p-1"><div class="dropdown">
  <button class="btn btn-outline-primary btn-block dropdown-toggle" type="button" data-toggle="dropdown">
    操作
  </button>
  <div class="dropdown-menu dropdown-menu-right">
    <a class="dropdown-item" target="_blank"  href="news-.htm">查看</a>
    <a class="dropdown-item" href="admin/article/update.jsp?id=">修改</a>
    <%-- <a class="dropdown-item" href="admin/user-delete.let?userId=<%=vo.getUserId()%>">删除</a> --%>
    <%-- <a class="dropdown-item" onclick="return confirm('您确定要删除这条记录吗?');"  href="admin/user-delete.let?userId=<%=vo.getUserId()%>">删除</a>--%>
    <a class="dropdown-item _delete" href="admin/user-delete.let?userId=<%=vo.getHglId()%>">删除</a>
  </div>
</div></td>
    </tr>
   <%} %>
  </tbody>
</table></div>
    </section>
    
<div class="modal fade" id="confirmDialog" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">确认对话框</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        您确定要删除这条记录吗？		
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        <a href="#" class="btn btn-primary">确定</a>
      </div>
    </div>
  </div>
</div>    
    
<script type="text/javascript">
/**
	var confirmDialog = $("#confirmDialog");
	
	$("._delete").on("click",function(){
		confirmDialog.find("a:last").attr("href",$(this).attr("href"));
		confirmDialog.modal("show");
		return false;
	});**/
	
	// alert("提示内容");
	// sys.alert("提示内容");
	
	// var ret = confirm("您确定要XXXXX吗？");
	// alert(ret);
	
	//sys.confirm("您确定要XXXXX吗？",function(ret){
	//	alert(ret);
	//});
	
	// sys.loading.show();
	// window.setTimeout(function(){
	// 	sys.loading.hide();
	// },3000);
	
	$("._delete").on("click",function(){
		let $this = $(this);
		sys.confirm("您需要删除这条记录吗？",function(ret){
			if(ret){
				location = $this.attr("href");
			}
		});
		return false;
	});
	
	var numSelect = document.getElementById("numSelect");
	numSelect.onchange = function(){
		window.location="admin/user-list.let?len="+this.value;
	}
</script>

  </body>
</html>
<%!
	//private  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private ThreadLocal<SimpleDateFormat> format = ThreadLocal.withInitial(new Supplier<SimpleDateFormat>(){
	public SimpleDateFormat get(){
		return new SimpleDateFormat("yyyy-MM-dd");
	}
});

private String format(Date date){
	if(date==null){
		return "-";
	} else {
		return format.get().format(date);
	}
}

private ThreadLocal<SimpleDateFormat> format1 = ThreadLocal.withInitial(new Supplier<SimpleDateFormat>(){
	public SimpleDateFormat get(){
		return new SimpleDateFormat("yyyy-MM-dd HH:mm");
	}
});

private String format1(Date date){
	if(date==null){
		return "-";
	} else {
		return format1.get().format(date);
	}
}

%>
